package timmytest;

import search.DepthFirstSearchVisitor;

public class TourFinder extends DepthFirstSearchVisitor<TourState, TourEdge> 
{
	private CityMap map;
	private TourState start;
	private City goal;
	public TourFinder(CityMap map, String start, String goal) {
		this.map = map;
		Tour t = new Tour();
		t.add(findCity(start));
		this.start = new TourState(t);
		this.goal = findCity(goal);
	}
	public City findCity(String name){
		for(City city:map.getNodes()){
			if(city.getData().equals(name))
				return city;
		}
		return null;
	}
	public TourState getStart() {
		return start;
	}

	public boolean isGoal(TourState state) {
		// really, we need to check that the 
		// Path contains all the nodes in the graph
		for(City c:map.getNodes()){
			if(!state.contains(c))
				return false;
		}
		return true;
		//return goal.getData().equals(state.getData());
	}

}
